<template>
  <div class="user-profile-component">
    <div class="d-flex align-items-center">
      <img
        :src="avatatUrl"
        :alt="user.nickName"
        class="rounded-circle img-thumbnail"
      />
      <div class="px-2">
        <h6 class="d-block mb-0">{{ user.nickName }}</h6>
        <span class="text-truncate text-muted d-block">{{
          user.description
        }}</span>
      </div>
    </div>
  </div>
</template>
<script lang='ts'>
import { defineComponent, computed, PropType } from "vue";
import { UserProps } from "../utils/interface";
export default defineComponent({
  name: "UserProfile",
  components: {},
  props: {
    user: {
      type: Object as PropType<UserProps>,
      required: true,
    },
  },
  setup(props) {
    const avatatUrl = computed(() => {
      if (!props.user.avatar) {
        return require("@/assets/defaultAvatar.png");
      } else {
        return (
          props.user.avatar.url + "?x-oss-process=image/resize,m_fill,h_50,w_50"
        );
      }
    });

    return {
      avatatUrl,
    };
  },
});
</script>
<style scoped>
.user-profile-component img {
  width: 50px;
  height: 50px;
}
</style>